trait Pilot {
    fn fly(&self);
}

trait Wizard {
    fn fly(&self);
}

struct Human;

impl Human {
    fn fly(&self) {
        println!("self Human fly");
    }
}

impl Pilot for Human {
    fn fly(&self) {
        println!("Pilot Human fly");
    }
}

impl Wizard for Human {
    fn fly(&self) {
        println!("Wizard Human fly");
    }
}

#[cfg(test)]
mod full_limit {
    use crate::basex::structx::trait_imp::{Human, Pilot, Wizard};

    #[test]
    fn method() {
        let person = Human;
        person.fly(); // 调用Human类型自身的方法
        Pilot::fly(&person); // 调用Pilot特征上的方法
        Wizard::fly(&person); // 调用Wizard特征上的方法

        <Human as Pilot>::fly(&person); //as 关键字，我们向 Rust 编译器提供了类型注解，也就是 Animal 就是 Dog
        let human = Human {};
        <Human as Pilot>::fly(&human);

        // 完全限定语法  <Type as Trait>::function(receiver_if_method, next_arg, ...);
    }
}

trait TA {
    fn base() {
        println!("trait A base");
    }
}

trait TB: TA {
    fn show() {
        println!("trait B:A show");
    }
    fn base() {
        println!("trait B:A base");
    }
}

struct Al;

impl TA for Al {
    fn base() {
        println!("TA Al base")
    }
}

impl TB for Al {
    fn show() {
        println!("TB Al show")
    }
}

#[cfg(test)]
mod same_method {
    use crate::basex::structx::trait_imp::{Al, TA, TB};

    #[test]
    fn method() {
        <Al as TA>::base();
        <Al as TB>::base();
        <Al as TB>::show();
    }
}
